#!/usr/bin/env python3.10
# -*- encoding: utf-8 -*-
'''
@File    :   schema.py
@Time    :   2024/02/06 11:06:26
@Author  :   windstarry 
@Version :   1.0
'''
# here put the import lib
from datetime import datetime
from typing import List, Optional, Type

from ninja import Field
from django.contrib.auth import get_user_model
from ninja_schema import Schema,ModelSchema,model_validator

# 获取用户模型
UserModel = get_user_model()


# 用户登录请求字段
class LoginSchema(Schema):
    username: str = Field(..., description="用户名")
    password: str = Field(..., description="密码")
    

class UserInfoSchema(ModelSchema):
    class Config:
        model = UserModel
        include = ("id", "username", "nickname", "avatar","status")
        
        
class UserTokenOutSchema(Schema):
    token: str
    user: UserInfoSchema
    token_exp_date: Optional[datetime]